import { defineStore } from 'pinia'
export const useHomeStore = defineStore('home',{
    state: () => ({
        // 关注列表
        followList: [] as number[],
        //喜欢列表
        like:[] as number[],
        //拉黑菜谱列表
        dislike:[] as number[],
        //收藏列表
        collect:[] as number[]
    }),
    getters: {

    },
    actions: {
        // 添加关注
        addFollowList(id:number){
            if(this.followList.includes(id)){
                return
            }
            this.followList.unshift(id)
        },
        // 取消关注
        removeFollowList(id:number){
            this.followList = this.followList.filter(item => item !== id);
        },
        // 添加不感兴趣拉黑菜谱
        addDislikeList(id:number){
            if(this.dislike.includes(id)){
                return
            }
            this.dislike.unshift(id)
        },
        // 添加喜欢
        addLikeList(id:number){
            if(this.like.includes(id)){
                return
            }
            this.like.unshift(id)
        },
        // 取消喜欢
        removeLikeList(id:number){
            this.like = this.like.filter(item => item !== id)
        },
        // 添加收藏
        addCollectList(id:number){
            if(this.collect.includes(id)){
                return
            }
            this.collect.unshift(id)
        },
        // 取消收藏
        removeCollectList(id:number){
            this.collect = this.collect.filter(item => item !== id)
        },
    },

    persist: true,
})
